package control;

import dao.DiaryDao;
import entity.DiaryInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/diary/diaryList")
public class DiaryList extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        DiaryDao dd=new DiaryDao();
        List<DiaryInfo> diaries=dd.findAll();
        req.setAttribute("diaries",diaries);
//        for (DiaryInfo d:diaries){
//            System.out.println(d);
//        }//用于控制台测试
        req.getRequestDispatcher("list.jsp").forward(req,resp);
    }
}
